'use strict';

import Base from './base.js';


export default class extends Base {
    /**
     * index action
     * @return {Promise} []
     */
    async indexAction(that){
        let cate = this.param('cate'),
            limit = this.param('limit') || 10;
        think.log('获取的类型为:'+cate);
        think.log('获取的limit为:'+limit);
        let newsObj = think.service('news'),
            newsService = new newsObj();
        let list = await newsService.pageByType(cate,that.param('page',1),that.param('limit',limit));
        list['ok'] = true;
        return this.jsonp(list);
    }
    async detailAction(that){
        let id = that.param('id');
        let newsObj = think.service('news'),
            newsService = new newsObj();
        let newsModel = await newsService.findById(id);
        let result = {ok:true};
        result['data'] = newsModel;
        return this.jsonp(result);
    }
}